package java_0629;

public class ThreadDemo15 {
    static class Count{
        public  int con = 0;
        synchronized public void increase(){
            con++;
        }
    }
    static Count count = new Count();
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(){
            @Override
            public void run() {
                for(int i=0;i<5000;i++){
                    count.increase();
                }
            }
        };
        Thread t2 = new Thread(){
            @Override
            public void run() {
                for(int i=0;i<5000;i++){
                    count.increase();
                }
            }
        };
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println(count.con);
    }
}
